A wide variety of addressing modes have been developed to provide more flexibility during operation of microcontrollers and microprocessors. For example, indexed addressing was developed to allow a programmer to access elements of a table or array more easily. Generally, in indexed addressing, a CPU of a data processor adds the contents of an index register to an offset supplied with an instruction to form an effective address. In some implementations, a pointer register other than the index register may be used.
In Motorola's MC6809 microprocessor, indexed addressing was expanded to include a constant offset mode. The MC6809 microprocessor is commercially available from Motorola, Inc. of Austin, Tex. In the constant offset mode of operation, an offset in two's complement form is added to the contents of one of a plurality of pointer registers to form an effective address. Offset sizes of 5-bits (-16 to +15), 8-bits (-128 to +127), and 16-bits (-32768 to +32767) are available. Additionally, no offset may also be specified. The 5-bit offset value is contained in a postbyte. A postbyte is a byte which is included after an operand and generally includes encoded information indicating a type of operation to be performed and a pointer register in addition to the 5-bit offset value. Because the type of operation to be performed and the pointer register must also be specified in the postbyte, the offset value is typically limited to a maximum value of five bits. The 8-bit and 16 -bit offset values are contained in the byte or bytes immediately following the postbyte.
An accumulator offset mode of operation may also be implemented in microcontrollers and microprocessors. In the accumulator offset mode of operation, the contents of the pointer register are added to an offset value contained in an accumulator to form the effective address.
The indexed addressing mode of operation generally available on microprocessors provides a flexible method for accessing addresses, especially when the addresses form a table or an array. However, in the case of a signed offset, the offset range is not symmetric about zero. As was previously stated, the offset ranges from -16 to +15, -128 to +127, or -32768 to +32767. Because the offset is signed, both the positive and negative limits of the offset range must reflect a sign bit. Hence, a value of +15 has a binary form of 01111. A binary value of 10000 represents a decimal value of -16 rather than a decimal value of +16 because the most significant bit must reflect the sign of the offset
Therefore, when a user of the microprocessor uses signed indexed addressing, the positive limit of the offset range is 2.sup.(n-1) -1, where n is the number of bits of the offset value, a value which is not commonly used. Most applications require an increment of a power of two number of bytes, such as eight or sixteen. Therefore, if the user must increment through a table in sixteen byte steps, the 8-bit offset must be used to provide an offset of sixteen because a 5-bit offset would have a maximum positive range of fifteen bytes. As was previously mentioned, the 8-bit offset generally requires an additional byte in the encoded instruction. Therefore, an additional byte of programming space must be used to specify the positive sixteen byte offset value. In many microcontroller and microprocessor applications, a limited amount of internal programming memory is provided and each byte of programming space is very valuable.
In addition to calculating the effective address using either the constant offset mode of operation or the accumulator offset mode of operation, a two's complement offset may be used to automatically increment or decrement a pointer register. When automatically incrementing, or autoincrementing, the contents of the pointer register are incremented by either one or two. When automatically decrementing, or autodecrementing, the contents of the pointer register are typically decremented by either one or two. Autoincrementing and autodecrementing are useful for accessing tables which store information. However, the value in the pointer register may only be modified by one or two bytes. Therefore, the autoincrementing and autodecrementing operations are typically only useful in limited situations in which a next needed piece of information is within one or two bytes of the address currently in the pointer register used to perform the operations.